package com.ma4567.remotecontroller;

import com.ma4567.remotecontroller.LocalController.LocalCommand;
import com.ma4567.remotecontroller.MysqlHelper.*;
import com.ma4567.remotecontroller.UserManager.UserManager;
import com.ma4567.remotecontroller.ffmpegManager.ffmpegController;
import com.ma4567.remotecontroller.util.NginxController;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;

import java.sql.SQLException;

@SpringBootApplication
public class RemoteControllerApplication {
	public static UserManager userManager;
	public static NginxController nginxController;

	public static void main(String[] args) throws SQLException {
		ConnectPool.createDataSource();

		userManager = new UserManager();
		TableUserManager.Init();
		TableLogManager.Init();
		Notes.Init();
		CalendarTodo.Init();

		SpringApplicationBuilder builder = new SpringApplicationBuilder(RemoteControllerApplication.class);
		builder.headless(false).run(args);

		LocalCommand localCommand = new LocalCommand();
	}

	public static void CloseApplication() {
		ffmpegController.StopStream();
		System.exit(0);
	}
}
